<template>
	<view class="content">
		<view class="success-item">
			<image src="/static/tabbar/3adf1ae20d1e3f45cc08c75cbf181b1.png" class="success-img"></image>
			<view class="success">投递成功</view>
			<view class="success-text">点击在线沟通跳转到消息</view>
			<view class="btn" @click="dialogue('您好，我在就业平台上看到贵公司的招聘信息，对贵公司【'+title+'】岗位很感兴趣，期待与您沟通。')">在线沟通
			</view>
		</view>
		<view class="job-block" v-if="jobList.length>0">
			<view class="title">猜你喜欢</view>
			<view class="position-block">
				<view
					@click="navigate('/page_other/job_hunting/job_detail/index?id='+item.id+ '&jobType=' +item.jobType)"
					class="list-item" v-for="(item,index) in jobList" :key="item.id">
					<view class="list-info">
						<view class="title">{{item.jobTitle}}</view>
						<view class="address">{{item.jobAddress}}</view>
						<view class="label-block">
							<view class="label-item" v-for="label in item.label">{{label}}</view>
						</view>
						<view class="wage" v-if="item.minSalary">{{item.minSalary}}-{{item.maxSalary}}<text class="unit">元</text></view>
						<view class="wage" v-else>面议</view>
						</view>
					</view>
					<view class="detail-info">
						<view class="name">{{item.comRecruiters.comPosition}}</view>
						<image mode="aspectFill" :src="item.comRecruiters.user.faceUrl" class="photo"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		sendHiMessage,
		getToAccount
	} from '@/util/im.js';
	import {
		GuessYouLoveApi
	} from '@/api/job_hunting.js';
	export default {
		data() {
			return {
				id: null,
				jobList: [],
				page: 1,
				limit: 6,
				jobType: null,
				mobile: '',
				title: ''
			}
		},
		methods: {
			dialogue(msg) {
				try {
					sendHiMessage(msg, this.mobile, this.id).finally(() => {
						this.showToast('发送成功');
					});
				} catch (e) {
					console.log(e);
				}
			},
			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			GuessYouLove() {
				GuessYouLoveApi({
					jobType: this.jobType,
					page: 1,
					limit: 6,
					pubId: this.id
				}).then((res) => {
					this.jobList = res.list ?? [];
				}).catch((res) => {
					console.log(res)
				})
			},
		},
		onLoad(e) {
			console.log(e)
			this.id = e.id;
			this.jobType = e.jobType
			this.mobile = e.mobile
			this.title = e.title
			this.imageUrl = this.globalConfig.imageUrl;
			this.GuessYouLove()
		}
	}
</script>

<style lang="scss" scoped>
	$box-shadow: 0 0 10px 0 #efefef;

	.content {
		width: 100%;
		padding: 30rpx;
		background: #fff;
		position: relative;
		padding-bottom: 120rpx;

		.success-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			background: #fff;

			.success-img {
				width: 300rpx;
				height: 300rpx;
			}

			.success {
				font-weight: bold;
				font-size: 38rpx;
			}

			.success-text {
				font-size: 26rpx;
				color: #999;
				margin-top: 15rpx;
			}

			.btn {
				width: 600rpx;
				height: 70rpx;
				border-radius: 40rpx;
				background-color: #FF7626;
				display: flex;
				justify-content: center;
				align-items: center;
				color: #fff;
				margin-top: 40rpx;
			}
		}

		.job-block {
			background-color: #F8F8F8;
			padding: 30rpx;
			margin-top: 30rpx;

			.title {
				font-size: 28rpx;
				margin-bottom: 20rpx;
			}

			.position-block {
				box-shadow: none;
				display: flex;
				flex-direction: column;
				margin-bottom: 0;

				.list-item {
					width: 100%;
					background: #fff;
					border-radius: 10rpx;
					box-shadow: $box-shadow;
					padding: 20rpx;
					display: flex;
					flex-direction: row;
					justify-content: center;
					margin-bottom: 20rpx;

					.detail-info {
						width: 260rpx;
						height: 200rpx;
						display: flex;
						flex-direction: row;
						flex-wrap: wrap;
						justify-content: center;
						align-items: center;

						.name {
							width: 110rpx;
							font-size: 24rpx;
							color: #999;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
							text-align: center;
							text-indent: 15rpx;
						}

						.photo {
							width: 70rpx;
							height: 70rpx;
							border-radius: 100%;
							background: #efefef;
						}

						.apply-btn {
							border: 1px solid #FE7526;
							border-radius: 8rpx;
							color: #FE7526;
							font-size: 24rpx;
							padding: 8rpx 28rpx;
							position: relative;
							left: 30rpx;
						}
					}

					.list-info {
						width: calc(100% - 180rpx);
						display: flex;
						flex-direction: column;

						>view {
							width: 100%;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
						}

						.title {
							color: #000;
							font-weight: bold;
							font-size: 34rpx;
							width: 360rpx;
						}

						.address {
							color: #999;
							font-size: 26rpx;
							margin-top: 20rpx;
						}

						.label-block {
							font-size: 24rpx;
							display: flex;
							flex-direction: row;
							flex-wrap: wrap;
							justify-content: left;
							margin-top: 20rpx;

							.label-item {
								padding: 8rpx 20rpx;
								background: #F5F6F8;
								color: #999;
								margin: 0 10rpx 20rpx 0;
							}
						}

						.wage {
							color: #FE7526;
							font-size: 36rpx;
							font-weight: bold;

							.unit {
								font-size: 28rpx;
								font-weight: normal;
							}
						}
					}
				}
			}
		}
	}
</style>
